#include <graphics.h>
#include <conio.h>
#include <Windows.h>
#include <time.h>
#include <stdio.h>
#include <string.h>

#pragma comment(lib,"Winmm.lib")
//定义画面大小
#define HIGH 640
#define WIDTH 640

IMAGE img_bk1, img_bk2;		//地面
IMAGE img_stu1, img_stu2;	//学生
IMAGE img_tea1, img_tea2;	//老师
IMAGE img_menu;             //菜单
IMAGE img_MAZE;				//迷宫背景
IMAGE img_SHOT;             //射击背景
IMAGE img_ROAD;				//拼图背景
IMAGE img_box1, img_box2;		//宝箱
IMAGE img_question1, img_question2;	//问题
IMAGE img_target1, img_target2; //靶子
IMAGE img_leftup, img_leftdown, img_rightup, img_rightdown, img_leftright, img_updown;  //拼图
IMAGE img_backroom;          //密室背景
IMAGE img_clue1, img_clue2, img_clue3, img_clue4;              //线索

struct background			//背景坐标
{
	int x;
	int y;
};
background bk;

struct target
{
	int x;
	int y;                   //靶子坐标
	int click;               //进入射击画面，0表示鼠标未点击靶子，1表示鼠标点击靶子，2表示靶子放对地方
};
target tar;

struct person
{
	float x;
	float y;					//人物坐标
	int status;				//朝向0表示下，1表示上，2表示左，3表示右
	int location;			//位置0表示在地图上，1表示在迷宫里，2表示在射击场地，3表示在拼图，4表示在密室，5表示在回答问题,6表示在最终通关
	int loca;				//进入关卡时位置是否被初始化，0表示没有，1表示被初始化过了
};
person stu;
person tea;

int down_s, up_s, left_s, right_s, down_t, up_t, left_t, right_t;	//移动时计数
int roadimage[5][5];				//拼图计数	
int keyone, keytwo;					//拼图计数
int gameStatus;			//游戏状态，0为菜单界面，1为游戏说明，2为正常游戏，3为结束游戏状态，4为暂停游戏界面
int MusicStatus[7];		//音乐状态，0表示播放过了，1表示没有播放；
int num;				//密室状态
int key;              //线索状态
float teacherspeed;		//老师移动速度
int Question;			//第几个问题
int answer[6];		//记录问题是否正确
int keynumber[4];      //线索个数

void menu();  //菜单界面
void pausemenu();   //游戏暂停后菜单界面
void startup();    //数据初始化
void show();    //显示画面
void updateWithoutInput();   //与用户输入无关的更新
void updateWithInput();   //与用户输入有关的更新
void gameover();     //游戏结束，后续处理
void readRecordFile();   //读取游戏数据文件存档
void writeRecordFile();   //存储游戏数据文件存档
void explain();           //游戏说明
void maze();              //迷宫
void shot();              //射击
void road();			  //拼图
void teacher();			  //老师
void question();		  //问题
void Backroom();          //密室

void PlayMusicOnce(char *fileName)						//播放一次音乐
{
	char cmdString[50] = "open ";
	strcat(cmdString, fileName);
	strcat(cmdString, " alias tmpmusic");
	mciSendString("close tmpmusic", NULL, 0, NULL);
	mciSendString(cmdString, NULL, 0, NULL);
	mciSendString("play tmpmusic", NULL, 0, NULL);
}
void PlayMusicForever(char *fileName)						//一直播放音乐
{
	char cmdString[50] = "open ";
	strcat(cmdString, fileName);
	strcat(cmdString, " alias tmpmusic");
	mciSendString("close tmpmusic", NULL, 0, NULL);
	mciSendString(cmdString, NULL, 0, NULL);
	mciSendString("play tmpmusic repeat", NULL, 0, NULL);
}

void startup()      //数据初始化
{
	int i, j;
	initgraph(HIGH, WIDTH);
	HWND hwnd = GetHWnd();       //设置窗口标题文字
	SetWindowText(hwnd, "为学楼逃亡");

	loadimage(&img_bk1, ".\\地面1.jpg");
	loadimage(&img_bk2, ".\\地面2.jpg");
	loadimage(&img_menu, ".\\菜单.jpg");
	loadimage(&img_stu1, ".\\学生2.jpg");
	loadimage(&img_stu2, ".\\学生1.jpg");
	loadimage(&img_tea1, ".\\老师2.jpg");
	loadimage(&img_tea2, ".\\老师1.jpg");
	loadimage(&img_MAZE, ".\\迷宫.jpg");
	loadimage(&img_SHOT, ".\\射击.jpg");
	loadimage(&img_ROAD, ".\\拼图.jpg");
	loadimage(&img_target1, ".\\靶子2.jpg");
	loadimage(&img_target2, ".\\靶子1.jpg");
	loadimage(&img_box1, ".\\宝箱2.jpg");
	loadimage(&img_box2, ".\\宝箱1.jpg");
	loadimage(&img_leftup, ".\\右下.jpg");
	loadimage(&img_leftdown, ".\\右上.jpg");
	loadimage(&img_rightup, ".\\左下.jpg");
	loadimage(&img_rightdown, ".\\左上.jpg");
	loadimage(&img_updown, ".\\竖直.jpg");
	loadimage(&img_leftright, ".\\水平.jpg");
	loadimage(&img_backroom, ".\\密室.jpg");
	loadimage(&img_question1, ".\\问题2.jpg");
	loadimage(&img_question2, ".\\问题1.jpg");
	loadimage(&img_clue1, ".\\线索1.jpg");
	loadimage(&img_clue2, ".\\线索2.jpg");
	loadimage(&img_clue3, ".\\线索3.jpg");
	loadimage(&img_clue4, ".\\线索4.jpg");

	stu.x = 320;
	stu.y = 320;
	stu.status = 0;
	stu.location = 0;
	stu.loca = 0;

	tea.x = 2500;
	tea.y = 1500;
	tea.status = 0;
	teacherspeed = 0.125;

	tar.x = 10;
	tar.y = 320;
	tar.click = 0;

	bk.x = 0;
	bk.y = 0;

	down_s = 0;
	up_s = 0;
	left_s = 0;
	right_s = 0;

	down_t = 0;
	up_t = 0;
	left_t = 0;
	right_t = 0;

	srand(time(0));
	for (i = 0; i < 5; i++)
		for (j = 0; j < 5; j++)
		{
			roadimage[i][j] = rand() % 4;
		}

	gameStatus = 0;
	num = 1;
	key = 0;
	keynumber[0] = 0;
	keynumber[1] = 0;
	keynumber[2] = 0;
	keynumber[3] = 0;

	MusicStatus[0] = 1;
	MusicStatus[1] = 1;
	MusicStatus[2] = 1;
	MusicStatus[3] = 1;
	MusicStatus[4] = 1;
	MusicStatus[5] = 1;
	MusicStatus[6] = 1;

	answer[0] = 3;
	answer[1] = 3;
	answer[2] = 3;
	answer[3] = 3;
	answer[4] = 3;
	answer[5] = 3;
	answer[6] = 3;

	keyone = 0;
	keytwo = 0;

	Question = 0;

	BeginBatchDraw();
}

void menu()
{
	putimage(0, 0, &img_menu);    //显示菜单背景图片
	setbkmode(TRANSPARENT);
	settextcolor(GREEN);
	settextstyle(70, 0, "黑体");
	outtextxy(WIDTH*0.25, HIGH*0.2, "为学楼逃亡");
	settextstyle(50, 0, "黑体");
	outtextxy(WIDTH*0.3, HIGH*0.4, "1 新游戏");
	outtextxy(WIDTH*0.3, HIGH*0.5, "2 读取游戏存档");
	outtextxy(WIDTH*0.3, HIGH*0.6, "3 游戏说明");
	outtextxy(WIDTH*0.3, HIGH*0.7, "4 退出");
	settextcolor(YELLOW);
	settextstyle(20, 0, _T("黑体"));
	outtextxy(WIDTH*0.6, HIGH*0.9, "温情提示：请务必牢记线索！");

	FlushBatchDraw();
	Sleep(2);

	char input;
	if (kbhit())  // 判断是否有输入
	{
		input = getch();  // 根据用户的不同输入来移动，不必输入回车
		if (input == '1')
			gameStatus = 2;
		else if (input == '2')
		{
			readRecordFile();
			gameStatus = 2;
		}
		else if (input == '3')
		{
			explain();
			gameStatus = 1;
		}
		else if (input == '4')
		{
			gameStatus = 3;
			exit(0);
		}
	}
}

void explain()
{
	putimage(0, 0, &img_menu);
	setbkmode(TRANSPARENT);
	settextcolor(RED);
	settextstyle(50, 0, "黑体");
	outtextxy(WIDTH*0.1, HIGH*0.2, "游戏说明");
	settextcolor(WHITE);
	settextstyle(30, 0, "黑体");
	outtextxy(WIDTH*0.1, HIGH*0.35, "wasd控制学生行走，w向上，s向下，a向左，");
	outtextxy(WIDTH*0.1, HIGH*0.4, "d向右");
	outtextxy(WIDTH*0.1, HIGH*0.45, "学生需躲避老师的追击，通过进入不同的教");
	outtextxy(WIDTH*0.1, HIGH*0.5, "室,集齐所有线索，逃离为学楼");
	outtextxy(WIDTH*0.1, HIGH*0.6, "ESC键暂停游戏");
	outtextxy(WIDTH*0.1, HIGH*0.7, "祝大家游戏愉快！");

	FlushBatchDraw();
	Sleep(2);

	char input;
	if (kbhit())
	{
		input = getch();
		if (input == 27) // ESC键的ACSII码为27
		{
			gameStatus = 0;
		}
	}
}

void pausemenu()
{
	putimage(0, 0, &img_menu);
	setbkmode(TRANSPARENT);
	settextcolor(GREEN);
	settextstyle(50, 0, "黑体");
	outtextxy(WIDTH*0.3, HIGH*0.4, "1 继续游戏");
	outtextxy(WIDTH*0.3, HIGH*0.5, "2 保存档案");
	outtextxy(WIDTH*0.3, HIGH*0.6, "3 退出");

	FlushBatchDraw();
	Sleep(2);

	char input;
	if (kbhit())  // 判断是否有输入
	{
		input = getch();  // 根据用户的不同输入来移动，不必输入回车
		if (input == '1')
			gameStatus = 2;
		else if (input == '2')
		{
			writeRecordFile();
			gameStatus = 2;
		}
		else if (input == '3')
		{
			gameStatus = 3;
			exit(0);
		}
	}
}

void maze()
{
	stu.location = 1;

	if (stu.loca == 0)
	{
		stu.x = 80;
		stu.y = 0;
		stu.loca = 1;
	}
	if (stu.x >= 530 && stu.x <= 540 && stu.y >= 600)
	{
		stu.location = 0;
		stu.loca = 0;
		bk.x = -340;
		bk.y = -330;
		stu.x = 320;
		stu.y = 320;
		key = 1;
		keynumber[0] = 1;
	}
}

void shot()
{
	stu.location = 2;

	MOUSEMSG m;		 //定义鼠标消息
	while (MouseHit())    //这个函数用于检测当前是否有鼠标消息
	{
		m = GetMouseMsg();
		if (m.x >= 50 && m.x <= 100 && m.y >= 340 && m.y <= 440)
		{
			if (m.uMsg == WM_LBUTTONDOWN)  //单击左键
			{
				tar.click = 1;
			}
		}
		if (tar.click == 1)
		{
			if (m.x >= 250 && m.x <= 300 && m.y >= 350 && m.y <= 400)
			{
				if (m.uMsg == WM_LBUTTONDOWN)
				{
					//单击鼠标左键靶子固定
					tar.x = 180;
					tar.y = 280;
					PlayMusicOnce(".\\解密胜利.mp3");
					Sleep(1000);
					tar.click = 2;
				}
			}
		}
		if (tar.click == 1)
		{
			if (m.uMsg == WM_MOUSEMOVE)
			{
				//靶子的位置就是鼠标的位置
				tar.x = m.x - 100;
				tar.y = m.y - 90;
			}
		}
	}
	if (tar.click == 2)
	{
		stu.location = 0;
		bk.x = 0;
		bk.y = -850;
		stu.x = 320;
		stu.y = 320;
		key = 2;
		keynumber[1] = 1;
	}
}

void road()
{
	stu.location = 3;

	int i, j;
	MOUSEMSG m;		 //定义鼠标消息
	while (MouseHit())    //这个函数用于检测当前是否有鼠标消息
	{
		m = GetMouseMsg();
		j = (m.x - 70) / 100;
		i = (m.y - 70) / 100;
		if (m.x >= 70 && m.x <= 570 && m.y >= 70 && m.y <= 570)
		{
			if (m.uMsg == WM_LBUTTONDOWN)
			{
				roadimage[i][j] = (roadimage[i][j] + 1) % 4;
			}
		}
	}
	if (roadimage[0][3] == 1 && roadimage[0][4] == 3)
		if (roadimage[1][1] == 2 && roadimage[1][2] == 3 && roadimage[1][4] % 2 == 0)
			if (roadimage[2][1] % 2 == 0 && roadimage[2][2] == 1 && roadimage[2][3] % 2 == 1 && roadimage[2][4] == 0)
				if (roadimage[3][1] == 1 && roadimage[3][2] == 3)
					if (roadimage[4][2] % 2 == 0)
					{
						keyone = 1;
					}
	if (roadimage[0][0] == 2 && roadimage[0][1] % 2 == 1 && roadimage[0][2] % 2 == 1 && roadimage[0][3] == 0)
		if (roadimage[1][0] % 2 == 0 && roadimage[1][2] == 2 && roadimage[1][3] == 3)
			if (roadimage[2][0] == 1 && roadimage[2][1] % 2 == 1 && roadimage[2][2] == 0 && roadimage[2][3] % 2 == 0)
				if (roadimage[3][2] == 2 && roadimage[3][3] == 0)
					if (roadimage[4][2] % 2 == 0)
					{
						keytwo = 1;
					}
}

void Backroom()
{
	stu.location = 4;
	MOUSEMSG m;		 //定义鼠标消息
	while (MouseHit())    //这个函数用于检测当前是否有鼠标消息
	{
		m = GetMouseMsg();
		if (m.x >= 560 && m.x <= 600 && m.y >= 570 && m.y <= 620)
		{
			if (m.uMsg == WM_LBUTTONDOWN)  //单击鼠标左键
			{
				setbkmode(TRANSPARENT);
				settextcolor(RED);
				settextstyle(50, 0, "黑体");
				outtextxy(WIDTH*0.2, HIGH*0.3, "恭喜你即将被传送到");
				outtextxy(WIDTH*0.2, HIGH*0.4, "老师的身边");
				outtextxy(WIDTH*0.2, HIGH*0.5, "注意转换思维");
				outtextxy(WIDTH*0.2, HIGH*0.6, "加油哦！");

				FlushBatchDraw();
				PlayMusicOnce(".\\解密胜利.mp3");
				Sleep(1000);
				num = 2;
			}
		}
	}
	if (num == 2)
	{
		stu.location = 0;
		bk.x = 0;
		bk.y = 0;
		stu.x = 320;
		stu.y = 320;
		tea.x = 320;
		tea.y = 320;
		key = 4;
		keynumber[3] = 1;
	}
}

void teacher()
{
	int x, y;
	if (stu.x > tea.x)
	{
		tea.status = 3;
		tea.x = tea.x + teacherspeed;
		right_t++;
	}
	else if (stu.x < tea.x)
	{
		tea.status = 2;
		tea.x = tea.x - teacherspeed;
		left_t++;
	}
	if (stu.y > tea.y)
	{
		tea.status = 0;
		tea.y = tea.y + teacherspeed;
		down_t++;
	}
	else if (stu.y < tea.y)
	{
		tea.status = 1;
		tea.y = tea.y - teacherspeed;
		up_t++;
	}

	x = (tea.x - stu.x)*(tea.x - stu.x);
	y = (tea.y - stu.y)*(tea.y - stu.y);
	if (x + y <= 250000)
	{
		if (MusicStatus[4] == 1)
		{
			PlayMusicForever(".\\逃跑.mp3");
			MusicStatus[4] = 0;
		}
	}

	if (stu.x == tea.x && stu.y == tea.y)
	{
		Sleep(1000);
		question();
		Question++;
	}
}

void question()
{
	stu.location = 5;
}

void readRecordFile()  //读取游戏数据文件存档
{
	FILE *fp;
	fp = fopen(".\\gameRecord.dat", "r");
	fscanf(fp, "%f %f %f %f %d %d %d %d %d %d %d %d %d %d", &stu.x, &stu.y, &tea.x, &tea.y, &tea.status, &stu.status, &stu.location, &stu.loca, &bk.x, &bk.y, &gameStatus, &key, &keynumber, &Question);
	fclose(fp);
}

void writeRecordFile()  //存储游戏数据文件存档
{
	FILE *fp;
	fp = fopen(".\\gameRecord.dat", "w");
	fprintf(fp, "%f %f %f %f %d %d %d %d %d %d %d %d %d %d %d", stu.x, stu.y, tea.x, tea.y, tea.status, stu.status, stu.location, stu.loca, bk.x, bk.y, gameStatus, key, keynumber, Question);
	fclose(fp);
}


void show()
{
	if (stu.location == 0)
	{
		if (keynumber[0]==0 || keynumber[1] == 0 || keynumber[2] == 0 || keynumber[3] == 0)
			putimage(bk.x, bk.y, &img_bk1);
		else if (keynumber[0] == 1 && keynumber[1] == 1 && keynumber[2] == 1 && keynumber[3] == 1)
			putimage(bk.x, bk.y, &img_bk2);

		if (stu.status == 0)
		{
			putimage(stu.x, stu.y, 32, 48, &img_stu1, 32 * down_s, 0, NOTSRCERASE);
			putimage(stu.x, stu.y, 32, 48, &img_stu2, 32 * down_s, 0, SRCINVERT);
		}
		if (stu.status == 1)
		{
			putimage(stu.x, stu.y, 32, 48, &img_stu1, 32 * up_s, 144, NOTSRCERASE);
			putimage(stu.x, stu.y, 32, 48, &img_stu2, 32 * up_s, 144, SRCINVERT);
		}
		if (stu.status == 2)
		{
			putimage(stu.x, stu.y, 32, 48, &img_stu1, 32 * left_s, 48, NOTSRCERASE);
			putimage(stu.x, stu.y, 32, 48, &img_stu2, 32 * left_s, 48, SRCINVERT);
		}
		if (stu.status == 3)
		{
			putimage(stu.x, stu.y, 32, 48, &img_stu1, 32 * right_s, 96, NOTSRCERASE);
			putimage(stu.x, stu.y, 32, 48, &img_stu2, 32 * right_s, 96, SRCINVERT);
		}

		if (tea.status == 0)
		{
			putimage(tea.x, tea.y, 32, 48, &img_tea1, 32 * down_t, 0, NOTSRCERASE);
			putimage(tea.x, tea.y, 32, 48, &img_tea2, 32 * down_t, 0, SRCINVERT);
		}
		if (tea.status == 1)
		{
			putimage(tea.x, tea.y, 32, 48, &img_tea1, 32 * up_t, 144, NOTSRCERASE);
			putimage(tea.x, tea.y, 32, 48, &img_tea2, 32 * up_t, 144, SRCINVERT);
		}
		if (tea.status == 2)
		{
			putimage(tea.x, tea.y, 32, 48, &img_tea1, 32 * left_t, 48, NOTSRCERASE);
			putimage(tea.x, tea.y, 32, 48, &img_tea2, 32 * left_t, 48, SRCINVERT);
		}
		if (tea.status == 3)
		{
			putimage(tea.x, tea.y, 32, 48, &img_tea1, 32 * right_t, 96, NOTSRCERASE);
			putimage(tea.x, tea.y, 32, 48, &img_tea2, 32 * right_t, 96, SRCINVERT);
		}
		if (MusicStatus[0] == 1)
		{
			PlayMusicForever(".\\背景音乐.mp3");
			MusicStatus[0] = 0;
			MusicStatus[1] = 1;
			MusicStatus[2] = 1;
			MusicStatus[3] = 1;
			MusicStatus[4] = 1;
			MusicStatus[5] = 1;
		}
		if (key == 1)
		{
			putimage(0, 0, &img_clue4, NOTSRCERASE);
			putimage(0, 0, &img_clue1, SRCINVERT);
		}
		if (key == 2)
		{
			putimage(100, 0, &img_clue4, NOTSRCERASE);
			putimage(100, 0, &img_clue2, SRCINVERT);
		}
		if (key == 3)
		{
			putimage(200, 0, &img_clue4, NOTSRCERASE);
			putimage(200, 0, &img_clue2, SRCINVERT);
		}
		if (key == 4)
		{
			putimage(300, 0, &img_clue4, NOTSRCERASE);
			putimage(300, 0, &img_clue3, SRCINVERT);
		}
	}
	else if (stu.location == 1)
	{
		putimage(0, 0, &img_MAZE);
		settextcolor(BLACK);
		settextstyle(40, 0, "黑体");
		outtextxy(0, 0, "看不见的路，宝箱处为出口");
		putimage(520, 600, 64, 64, &img_box1, 0, 0, NOTSRCERASE);
		putimage(520, 600, 64, 64, &img_box2, 0, 0, SRCINVERT);
		if (stu.status == 0)
		{
			putimage(stu.x, stu.y, 32, 48, &img_stu1, 32 * down_s, 0, NOTSRCERASE);
			putimage(stu.x, stu.y, 32, 48, &img_stu2, 32 * down_s, 0, SRCINVERT);
		}
		if (stu.status == 1)
		{
			putimage(stu.x, stu.y, 32, 48, &img_stu1, 32 * up_s, 144, NOTSRCERASE);
			putimage(stu.x, stu.y, 32, 48, &img_stu2, 32 * up_s, 144, SRCINVERT);
		}
		if (stu.status == 2)
		{
			putimage(stu.x, stu.y, 32, 48, &img_stu1, 32 * left_s, 48, NOTSRCERASE);
			putimage(stu.x, stu.y, 32, 48, &img_stu2, 32 * left_s, 48, SRCINVERT);
		}
		if (stu.status == 3)
		{
			putimage(stu.x, stu.y, 32, 48, &img_stu1, 32 * right_s, 96, NOTSRCERASE);
			putimage(stu.x, stu.y, 32, 48, &img_stu2, 32 * right_s, 96, SRCINVERT);
		}
		if (MusicStatus[1] == 1)
		{
			PlayMusicForever(".\\解密.mp3");
			MusicStatus[1] = 0;
			MusicStatus[0] = 1;
			MusicStatus[2] = 1;
			MusicStatus[3] = 1;
			MusicStatus[4] = 1;
			MusicStatus[5] = 1;
		}
	}
	else if (stu.location == 2)
	{
		putimage(0, 0, &img_SHOT);
		settextcolor(BLACK);
		settextstyle(40, 0, "黑体");
		outtextxy(0, 0, "这个人枪法极差，需要让他一定能");
		outtextxy(0, 40, "打到靶子");
		putimage(tar.x, tar.y, &img_target1, NOTSRCERASE);
		putimage(tar.x, tar.y, &img_target2, SRCINVERT);
		if (MusicStatus[2] == 1)
		{
			PlayMusicForever(".\\解密.mp3");
			MusicStatus[2] = 0;
			MusicStatus[0] = 1;
			MusicStatus[1] = 1;
			MusicStatus[3] = 1;
			MusicStatus[4] = 1;
			MusicStatus[5] = 1;
		}
	}
	else if (stu.location == 3)
	{
		int i, j;
		putimage(0, 0, &img_ROAD);
		putimage(400, 22, 32, 48, &img_stu1, 64, 0, NOTSRCERASE);
		putimage(400, 22, 32, 48, &img_stu2, 64, 0, SRCINVERT);
		if (keyone == 1 && keytwo == 1)
		{
			putimage(290, 560, 64, 64, &img_box1, 64, 0, NOTSRCERASE);
			putimage(290, 560, 64, 64, &img_box2, 64, 0, SRCINVERT);
		}
		else
		{
			putimage(290, 560, 64, 64, &img_box1, 0, 0, NOTSRCERASE);
			putimage(290, 560, 64, 64, &img_box2, 0, 0, SRCINVERT);
		}
		for (i = 0; i < 5; i++)
		{
			for (j = 0; j < 5; j++)
			{
				if (i == 0 && j != 1 && j != 2)
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftup);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightup);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightdown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftdown);
				}
				else if ((i == 0 && j == 1) || (i == 0 && j == 2))
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
				}

				if (i == 1 && j != 0 && j != 4)
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftup);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightup);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightdown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftdown);
				}
				else if ((i == 1 && j == 0) || (i == 1 && j == 4))
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
				}

				if (i == 2 && j != 1 && j != 3)
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftup);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightup);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightdown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftdown);
				}
				else if ((i == 2 && j == 1) || (i == 2 && j == 3))
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
				}

				if (i == 3 && j != 4)
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftup);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightup);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightdown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftdown);
				}
				else if (i == 3 && j == 4)
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
				}

				if (i == 4 && j != 1 && j != 2 && j != 3)
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftup);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightup);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_rightdown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftdown);
				}
				else if ((i == 4 && j == 1) || (i == 4 && j == 2) || (i == 4 && j == 3))
				{
					if (roadimage[i][j] == 0)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 1)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
					else if (roadimage[i][j] == 2)
						putimage(70 + 100 * j, 70 + 100 * i, &img_updown);
					else if (roadimage[i][j] == 3)
						putimage(70 + 100 * j, 70 + 100 * i, &img_leftright);
				}
			}
		}
		if (MusicStatus[3] == 1)
		{
			PlayMusicForever(".\\解密.mp3");
			MusicStatus[3] = 0;
			MusicStatus[0] = 1;
			MusicStatus[1] = 1;
			MusicStatus[2] = 1;
			MusicStatus[4] = 1;
			MusicStatus[5] = 1;
		}
		settextcolor(RED);
		settextstyle(30, 0, "黑体");
		outtextxy(0, 0, "你需要找到两条通往宝箱的路");
		outtextxy(0, 30, "点击道路以旋转");
		if (keyone == 1 || keytwo == 1)
			outtextxy(0, 570, "你已经找到了一条路");
		if(keyone==1 && keytwo==1)
			outtextxy(0, 600, "你已经找到了两条路");
		if (keyone == 1 && keytwo == 1)
		{
			stu.location = 0;
			stu.y = 140;
			key = 3;
			keynumber[2] = 1;
		}
	}
	else if (stu.location == 4)
	{
		putimage(0, 0, &img_backroom);
		settextcolor(RED);
		settextstyle(40, 0, "黑体");
		outtextxy(0, 0, "找到一本黑色的书");
		if (MusicStatus[4] == 1)
		{
			PlayMusicForever(".\\解密.mp3");
			MusicStatus[4] = 0;
			MusicStatus[0] = 1;
			MusicStatus[1] = 1;
			MusicStatus[2] = 1;
			MusicStatus[3] = 1;
			MusicStatus[5] = 1;
		}
	}
	else if (stu.location == 5)
	{
		putimage(0, 100, &img_question1, NOTSRCERASE);
		putimage(0, 100, &img_question2, SRCINVERT);
		if (Question == 1)
		{
			settextcolor(BLACK);
			settextstyle(40, 0, "黑体");
			outtextxy(120, 150, "7111=0      5555=0");
			outtextxy(120, 190, "8809=6      8193=3");
			outtextxy(120, 230, "6666=4      4398=3");
			outtextxy(120, 270, "2222=0      9038=4");
			outtextxy(120, 310, "6666=4      4398=3");
			outtextxy(120, 350, "7662=2      3148=2");
			outtextxy(120, 390, "9313=1");
			outtextxy(120, 430, "0000=4");
			settextcolor(RED);
			settextstyle(50, 0, "黑体");
			outtextxy(360, 400, "2889=?");
			settextcolor(BLACK);
			settextstyle(40, 0, "黑体");
			outtextxy(120, 500, "A、5       B、6");
			outtextxy(120, 540, "C、4       D、2");

			if (answer[0] == 1)
			{
				settextcolor(RED);
				settextstyle(70, 0, "黑体");
				outtextxy(200, 280, "答对了");
			}
			if (answer[0] == 0)
			{
				settextcolor(BLACK);
				settextstyle(70, 0, "黑体");
				outtextxy(100, 280, "答错了，答案是A");
			}
		}
		else if (Question == 2)
		{
			settextcolor(BLACK);
			settextstyle(40, 0, "黑体");
			outtextxy(240, 150, "5+3=28");
			outtextxy(240, 190, "9+1=810");
			outtextxy(240, 230, "8+6=214");
			outtextxy(240, 270, "5+4=19");
			settextcolor(RED);
			settextstyle(50, 0, "黑体");
			outtextxy(220, 350, "7+3=???");
			settextcolor(BLACK);
			settextstyle(40, 0, "黑体");
			outtextxy(120, 500, "A、104       B、21");
			outtextxy(120, 540, "C、410       D、24");

			if (answer[1] == 1)
			{
				settextcolor(RED);
				settextstyle(70, 0, "黑体");
				outtextxy(200, 280, "答对了");
			}
			if (answer[1] == 0)
			{
				settextcolor(BLACK);
				settextstyle(70, 0, "黑体");
				outtextxy(100, 280, "答错了，答案是C");
			}
		}
		else if (Question == 3)
		{
			settextcolor(BLACK);
			settextstyle(50, 0, "黑体");
			outtextxy(120, 150, "4");
			outtextxy(120, 200, "6   2");
			outtextxy(120, 250, "9   3   1");
			outtextxy(120, 300, "19  10  7  ?");
			settextstyle(40, 0, "黑体");
			outtextxy(120, 500, "A、7       B、6");
			outtextxy(120, 540, "C、1       D、8");

			if (answer[2] == 1)
			{
				settextcolor(RED);
				settextstyle(70, 0, "黑体");
				outtextxy(200, 280, "答对了");
			}
			if (answer[2] == 0)
			{
				settextcolor(BLACK);
				settextstyle(70, 0, "黑体");
				outtextxy(100, 280, "答错了，答案是B");
			}
		}
		else if (Question == 4)
		{
			settextcolor(BLACK);
			settextstyle(40, 0, "黑体");
			outtextxy(120, 150, "2   4   6");
			outtextxy(120, 190, "   28");
			outtextxy(370, 150, "3   5   7");
			outtextxy(370, 190, "   34");
			outtextxy(120, 250, "1   2   3");
			outtextxy(120, 290, "    7");
			outtextxy(370, 250, "5   ?   7");
			outtextxy(370, 290, "   38");
			settextstyle(40, 0, "黑体");
			outtextxy(120, 500, "A、5       B、7");
			outtextxy(120, 540, "C、3       D、6");

			if (answer[3] == 1)
			{
				settextcolor(RED);
				settextstyle(70, 0, "黑体");
				outtextxy(200, 280, "答对了");
			}
			if (answer[3] == 0)
			{
				settextcolor(BLACK);
				settextstyle(70, 0, "黑体");
				outtextxy(100, 280, "答错了，答案是D");
			}
		}
		else if (Question == 5)
		{
			settextcolor(BLACK);
			settextstyle(40, 0, "黑体");
			outtextxy(240, 150, "2+3=10");
			outtextxy(240, 190, "8+4=96");
			outtextxy(240, 230, "6+5=66");
			settextcolor(RED);
			settextstyle(50, 0, "黑体");
			outtextxy(220, 270, "9+5=???");
			settextcolor(BLACK);
			settextstyle(40, 0, "黑体");
			outtextxy(120, 500, "A、126       B、45");
			outtextxy(120, 540, "C、36        D、70");

			if (answer[4] == 1)
			{
				settextcolor(RED);
				settextstyle(70, 0, "黑体");
				outtextxy(200, 280, "答对了");
			}
			if (answer[4] == 0)
			{
				settextcolor(BLACK);
				settextstyle(70, 0, "黑体");
				outtextxy(100, 280, "答错了，答案是A");
			}
		}
		else if (Question == 6)
		{
			settextcolor(BLACK);
			settextstyle(40, 0, "黑体");
			outtextxy(120, 150, "老师已经跑不动了");
			outtextxy(120, 190, "他不会再追了");
			settextcolor(BLACK);
			settextstyle(40, 0, "黑体");
			outtextxy(120, 500, "（按E）");
		}

		if (MusicStatus[5] == 1)
		{
			PlayMusicForever(".\\被老师抓到.mp3");
			MusicStatus[5] = 0;
			MusicStatus[0] = 1;
			MusicStatus[1] = 1;
			MusicStatus[2] = 1;
			MusicStatus[3] = 1;
			MusicStatus[4] = 1;
		}
	}
	else if (stu.location == 6)
	{
		settextcolor(BLACK);
		settextstyle(50, 0, "黑体");
		outtextxy(0, 0, "回想下线索，联系实际");
		outtextxy(0, 50, "选择哪一个是正确的顺序");
		settextstyle(40, 0, "黑体");
		outtextxy(50, 300, "A、1 0  1 6       B、0 1  1 6");
		outtextxy(50, 340, "C、0 6  1 1       D、6 1  1 1");
		if (answer[5] == 1)
		{
			settextcolor(RED);
			settextstyle(70, 0, "黑体");
			outtextxy(200, 280, "游戏胜利");
			if (MusicStatus[6] == 1)
			{
				PlayMusicForever(".\\胜利.mp3");
				MusicStatus[6] = 0;
			}
		}
		if (answer[5] == 0)
		{
			settextcolor(BLACK);
			settextstyle(70, 0, "黑体");
			outtextxy(100, 280, "答错了，反正是选择题");
		}
	}
	FlushBatchDraw();
}

void updateWithoutInput()
{
	while (gameStatus == 0)
	{
		menu();    //菜单界面
	}
	while (gameStatus == 1)
	{
		explain();   //游戏说明
	}
	while (gameStatus == 4)
	{
		pausemenu();   //游戏暂停
	}

	if (bk.x >= -280 && bk.x <= -200 && bk.y == -360)
	{
		maze();         //迷宫
	}
	else if (bk.x >= -40 && bk.x <= 30 && bk.y == -870 && stu.x >= 200 && stu.x <= 300)
	{
		shot();         //射击
	}
	else if (bk.x >= -2270 && bk.x <= -2180 && bk.y >= -10 && bk.y <= 10 && stu.y >= 160 && stu.y <= 170)
	{
		road();         //拼图
	}
	else if (bk.x >= -1930 && bk.x <= -1800 && bk.y == -850 && stu.x >= 300 && stu.x <= 400)
	{
		Backroom();     //密室
	}

	if (keynumber[0] == 1 && keynumber[1] == 1 && keynumber[2] == 1 && keynumber[3] == 1)
	{
		if (bk.x >= -1680 && bk.x <= -1040 && bk.y <= -1080 && stu.y >= 470 && stu.y <= 590)
		{
			Sleep(1000);
			stu.location = 6;
		}
	}

	if (gameStatus == 2)
	{
		if (stu.location == 0)
			teacher();
	}

	if (Question == 1)
	{
		if (answer[0] <= 1)
		{
			Sleep(3000);
			stu.location = 0;
			tea.x = 2500;
			tea.y = 1500;
			tea.status = 0;
			answer[0] = 3;
		}
	}
	else if (Question == 2)
	{
		if (answer[1] <= 1)
		{
			Sleep(3000);
			stu.location = 0;
			tea.x = 2500;
			tea.y = 1500;
			tea.status = 0;
			answer[1] = 3;
		}
	}
	else if (Question == 3)
	{
		if (answer[2] <= 1)
		{
			Sleep(3000);
			stu.location = 0;
			tea.x = 2500;
			tea.y = 1500;
			tea.status = 0;
			answer[2] = 3;
		}
	}
	else if (Question == 4)
	{
		if (answer[3] <= 1)
		{
			Sleep(3000);
			stu.location = 0;
			tea.x = 2500;
			tea.y = 1500;
			tea.status = 0;
			answer[3] = 3;
		}
	}
	else if (Question == 5)
	{
		if (answer[4] <= 1)
		{
			Sleep(3000);
			stu.location = 0;
			tea.x = 2500;
			tea.y = 1500;
			tea.status = 0;
			answer[4] = 3;
		}
	}
	else if (Question == 6)
	{
		if (answer[5] <= 1)
		{
			Sleep(3000);
			stu.location = 0;
			tea.x = 2500;
			tea.y = 1500;
			teacherspeed = 0;
			Question++;
			answer[5] = 3;
		}
	}
}

void updateWithInput()
{
	char input;
	if (kbhit())
	{
		input = getch();
		if (input == 27) // ESC键的ACSII码为27
		{
			gameStatus = 4;
		}
		if (stu.location == 0)
		{
			if (input == 's')
			{
				if (bk.y >= -1079 && bk.y <= 10 && stu.y >= 320)
				{
					bk.y = bk.y - 10;
					tea.y = tea.y - 10;
				}
				stu.status = 0;
				up_s = 0;
				left_s = 0;
				right_s = 0;
				clearrectangle(stu.x, stu.y, stu.x + 32, stu.y + 48);
				if (bk.y >= -10 && bk.y <= 0 && stu.y <= 320 && stu.y >= 0)
					stu.y = stu.y + 10;
				else if (bk.y >= -1089 && bk.y <= -1079 && stu.y >= 320 && stu.y <= 580)
					stu.y = stu.y + 10;
				down_s = down_s + 1;
			}
			if (input == 'w')
			{
				if (bk.y >= -1089 && bk.y <= -10 && stu.y <= 330)
				{
					bk.y = bk.y + 10;
					tea.y = tea.y + 10;
				}
				stu.status = 1;
				down_s = 0;
				left_s = 0;
				right_s = 0;
				clearrectangle(stu.x, stu.y, stu.x + 32, stu.y + 48);
				if (bk.y >= -10 && bk.y <= 0 && stu.y <= 330 && stu.y >= 10)
					stu.y = stu.y - 10;
				else if (bk.y >= -1089 && bk.y <= -1079 && stu.y >= 320 && stu.y <= 620)
					stu.y = stu.y - 10;
				up_s = up_s + 1;
			}
			if (input == 'a')
			{
				if (bk.x >= -2460 && bk.x <= -10 && stu.x <= 330)
				{
					bk.x = bk.x + 10;
					tea.x = tea.x + 10;
				}
				stu.status = 2;
				down_s = 0;
				up_s = 0;
				right_s = 0;
				clearrectangle(stu.x, stu.y, stu.x + 32, stu.y + 48);
				if (bk.x >= -10 && bk.x <= 0 && stu.x <= 330 && stu.x >= 10)
					stu.x = stu.x - 10;
				else if (bk.x <= -2450 && bk.x >= -2460 && stu.x >= 310 && stu.x <= 620)
					stu.x = stu.x - 10;
				left_s = left_s + 1;
			}
			if (input == 'd')
			{
				if (bk.x >= -2450 && bk.x <= 10 && stu.x >= 320)
				{
					bk.x = bk.x - 10;
					tea.x = tea.x - 10;
				}
				stu.status = 3;
				down_s = 0;
				up_s = 0;
				left_s = 0;
				clearrectangle(stu.x, stu.y, stu.x + 32, stu.y + 48);
				if (bk.x <= -2450 && bk.x >= -2460 && stu.x >= 310 && stu.x <= 600)
					stu.x = stu.x + 10;
				else if (bk.x >= -10 && bk.x <= 0 && stu.x <= 320 && stu.x >= 0)
					stu.x = stu.x + 10;
				right_s = right_s + 1;
			}
		}
		else if (stu.location == 1)
		{
			if (input == 'a')
			{
				stu.status = 2;
				down_s = 0;
				up_s = 0;
				right_s = 0;
				clearrectangle(stu.x, stu.y, stu.x + 32, stu.y + 48);
				if (stu.x >= 160 && stu.x <= 530 && stu.y >= 50 && stu.y <= 60)
					stu.x = stu.x - 10;
				else if (stu.x >= 230 && stu.x <= 390 && stu.y >= 130 && stu.y <= 140)
					stu.x = stu.x - 10;
				else if (stu.x >= 230 && stu.x <= 390 && stu.y >= 210 && stu.y <= 240)
					stu.x = stu.x - 10;
				else if (stu.x >= 160 && stu.x <= 390 && stu.y >= 290 && stu.y <= 300)
					stu.x = stu.x - 10;
				else if (stu.x >= 90 && stu.x <= 390 && stu.y >= 370 && stu.y <= 380)
					stu.x = stu.x - 10;
				else if (stu.x >= 90 && stu.x <= 390 && stu.y >= 450 && stu.y <= 460)
					stu.x = stu.x - 10;
				else if (stu.x >= 450 && stu.x <= 530 && stu.y >= 450 && stu.y <= 460)
					stu.x = stu.x - 10;
				else if (stu.x >= 90 && stu.x <= 460 && stu.y >= 530 && stu.y <= 540)
					stu.x = stu.x - 10;
				left_s = left_s + 1;
			}
			if (input == 'd')
			{
				stu.status = 3;
				down_s = 0;
				up_s = 0;
				left_s = 0;
				clearrectangle(stu.x, stu.y, stu.x + 32, stu.y + 48);
				if (stu.x >= 150 && stu.x <= 520 && stu.y >= 50 && stu.y <= 60)
					stu.x = stu.x + 10;
				else if (stu.x >= 220 && stu.x <= 380 && stu.y >= 130 && stu.y <= 140)
					stu.x = stu.x + 10;
				else if (stu.x >= 220 && stu.x <= 380 && stu.y >= 210 && stu.y <= 240)
					stu.x = stu.x + 10;
				else if (stu.x >= 150 && stu.x <= 380 && stu.y >= 290 && stu.y <= 300)
					stu.x = stu.x + 10;
				else if (stu.x >= 80 && stu.x <= 380 && stu.y >= 370 && stu.y <= 380)
					stu.x = stu.x + 10;
				else if (stu.x >= 80 && stu.x <= 380 && stu.y >= 450 && stu.y <= 460)
					stu.x = stu.x + 10;
				else if (stu.x >= 440 && stu.x <= 520 && stu.y >= 450 && stu.y <= 460)
					stu.x = stu.x + 10;
				else if (stu.x >= 80 && stu.x <= 450 && stu.y >= 530 && stu.y <= 540)
					stu.x = stu.x + 10;
				right_s = right_s + 1;
			}
			if (input == 'w')
			{
				stu.status = 1;
				down_s = 0;
				left_s = 0;
				right_s = 0;
				clearrectangle(stu.x, stu.y, stu.x + 32, stu.y + 48);
				if (stu.x >= 70 && stu.x <= 100 && stu.y >= 10 && stu.y <= 540)
					stu.y = stu.y - 10;
				else if (stu.x >= 150 && stu.x <= 170 && stu.y >= 60 && stu.y <= 300)
					stu.y = stu.y - 10;
				else if (stu.x >= 220 && stu.x <= 240 && stu.y >= 140 && stu.y <= 240)
					stu.y = stu.y - 10;
				else if (stu.x >= 370 && stu.x <= 390 && stu.y >= 140 && stu.y <= 460)
					stu.y = stu.y - 10;
				else if (stu.x >= 440 && stu.x <= 460 && stu.y >= 60 && stu.y <= 460)
					stu.y = stu.y - 10;
				else if (stu.x >= 510 && stu.x <= 530 && stu.y >= 60 && stu.y <= 380)
					stu.y = stu.y - 10;
				else if (stu.x >= 510 && stu.x <= 530 && stu.y >= 460 && stu.y <= 630)
					stu.y = stu.y - 10;
				up_s = up_s + 1;
			}
			if (input == 's')
			{
				stu.status = 0;
				up_s = 0;
				left_s = 0;
				right_s = 0;
				clearrectangle(stu.x, stu.y, stu.x + 32, stu.y + 48);
				if (stu.x >= 70 && stu.x <= 100 && stu.y >= 0 && stu.y <= 530)
					stu.y = stu.y + 10;
				else if (stu.x >= 150 && stu.x <= 170 && stu.y >= 50 && stu.y <= 290)
					stu.y = stu.y + 10;
				else if (stu.x >= 220 && stu.x <= 240 && stu.y >= 130 && stu.y <= 230)
					stu.y = stu.y + 10;
				else if (stu.x >= 370 && stu.x <= 390 && stu.y >= 130 && stu.y <= 450)
					stu.y = stu.y + 10;
				else if (stu.x >= 440 && stu.x <= 460 && stu.y >= 50 && stu.y <= 450)
					stu.y = stu.y + 10;
				else if (stu.x >= 510 && stu.x <= 530 && stu.y >= 50 && stu.y <= 370)
					stu.y = stu.y + 10;
				else if (stu.x >= 510 && stu.x <= 530 && stu.y >= 450 && stu.y <= 590)
					stu.y = stu.y + 10;
				down_s = down_s + 1;
			}
		}
		else if (stu.location == 5)
		{
			if (input == 'a')
			{
				if (Question == 1)
					answer[0] = 1;
				else if (Question == 2)
					answer[1] = 0;
				else if (Question == 3)
					answer[2] = 0;
				else if (Question == 4)
					answer[3] = 0;
				else if (Question == 5)
					answer[4] = 1;
			}
			if (input == 'b')
			{
				if (Question == 1)
					answer[0] = 0;
				else if (Question == 2)
					answer[1] = 0;
				else if (Question == 3)
					answer[2] = 1;
				else if (Question == 4)
					answer[3] = 0;
				else if (Question == 5)
					answer[4] = 0;
			}
			if (input == 'c')
			{
				if (Question == 1)
					answer[0] = 0;
				else if (Question == 2)
					answer[1] = 1;
				else if (Question == 3)
					answer[2] = 0;
				else if (Question == 4)
					answer[3] = 0;
				else if (Question == 5)
					answer[4] = 0;
			}
			if (input == 'd')
			{
				if (Question == 1)
					answer[0] = 0;
				else if (Question == 2)
					answer[1] = 0;
				else if (Question == 3)
					answer[2] = 0;
				else if (Question == 4)
					answer[3] = 1;
				else if (Question == 5)
					answer[4] = 0;
			}
			if (input == 'e')
			{
				if (Question == 6)
					answer[5] = 1;
			}
		}
		else if (stu.location == 6)
		{
			if (input == 'a')
				answer[5] = 0;
			if (input == 'b')
				answer[5] = 1;
			if (input == 'c')
				answer[5] = 0;
			if (input == 'd')
				answer[5] = 0;
		}
	}

	if (down_s == 4)
		down_s = 0;
	if (up_s == 4)
		up_s = 0;
	if (left_s == 4)
		left_s = 0;
	if (right_s == 4)
		right_s = 0;
	if (down_t == 4)
		down_t = 0;
	if (up_t == 4)
		up_t = 0;
	if (left_t == 4)
		left_t = 0;
	if (right_t == 4)
		right_t = 0;

}

void gameover()
{
	EndBatchDraw();
	getch();
	closegraph();
}
int main()
{
	startup();  // 数据初始化	
	while (1)  //  游戏循环执行
	{
		show();  // 显示新画面
		updateWithoutInput();  // 与用户输入无关的更新
		updateWithInput();     // 与用户输入有关的更新
	}
	gameover();     // 游戏结束、后续处理
	return 0;
}